import axios from 'axios'

const service = axios.create({
    baseURL: '/api',
    timeout: 5000
})

service.interceptors.response.use(
    response => {
        console.log(response)
        // eslint-disable-next-line no-empty
        if (response.status === 200 && response.data) {
            console.log(response)
            return response.data
        } else {
            return Promise.reject(new Error('请求失败'))
        }
    },
    error => {
        return Promise.reject(error)
    }
)

export default service

